package com.lechuang.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lechuang.common.model.BaseEntity;
import com.lechuang.user.entity.UserConsignee;
import com.lechuang.user.service.UserConsigneeService;
import com.lechuang.user.mapper.UserConsigneeMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author apple
* @description 针对表【user_consignee(用户收货地址)】的数据库操作Service实现
* @createDate 2024-06-24 10:32:59
*/
@Service
public class UserConsigneeServiceImpl extends ServiceImpl<UserConsigneeMapper, UserConsignee>
    implements UserConsigneeService{

    @Resource
    private UserConsigneeMapper userConsigneeMapper;

    @Override
    public List<UserConsignee> queryByUserId(Long userId) {
        return this.lambdaQuery()
                .eq(UserConsignee::getUserId,userId)
                .eq(BaseEntity::getStatus,BaseEntity.STATUS_NORMAL)
                .orderByDesc(BaseEntity::getId)
                .list();
    }

    @Override
    public List<UserConsignee> queryByUserIdAndDefaultFlag(Long userId, Integer defaultFlag) {
        return this.lambdaQuery()
                .eq(UserConsignee::getUserId,userId)
                .eq(UserConsignee::getDefaultFlag,defaultFlag)
                .eq(BaseEntity::getStatus,BaseEntity.STATUS_NORMAL)
                .orderByDesc(BaseEntity::getId)
                .list();
    }

    @Override
    public void updateDefaultFlagByIds(List<Long> idList, Integer defalutFlag) {
        userConsigneeMapper.updateDefaultFlagByIds(idList,defalutFlag);
    }
}




